<link rel="stylesheet" href="/Content/FileUpload/css/jquery.fileupload.css" />
<link href="/Content/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="/Content/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<script src="/Content/js/plugins/sweetalert/sweetalert.min.js"></script>
<link rel="stylesheet" href="/Content/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="/Content/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/Content/kindeditor/lang/zh-CN.js"></script>
<div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>APP设置</h5>
                            <span style="float:right"><a href="#" class="push">推送更新</a></span>
                        </div>
                        <div class="ibox-content">
                            <form  action="/index.php/Home/Index/appset2" id="myform" method="post" class="form-horizontal"  enctype="multipart/form-data">
                             
								
								
							
								<div class="form-group"><label class="col-sm-2 control-label">APP版本</label>
                                    <div class="col-sm-10">
									<input type="text" name="version" class="form-control" value="{$version}"></div>
                                </div>
								<div class="form-group"><label class="col-sm-2 control-label">上传APP</label>
                                    <div class="col-sm-10">
									<span class="btn btn-success fileinput-button">
											<i class="glyphicon glyphicon-plus"></i>
											<span>添加</span>
										  <input id="fileupload" type="file" name="imgFile" multiple>
											


										</span>
										 <div id="progress" class="progress progress-striped active">
            <div class="progress-bar" role="progressbar"></div>
        </div>
											<div id="showpic">
											  <if condition="$apkurl neq ''" >
											
										 <a target='_blank' href="/{$apkurl}">文件</a>
										  </else>
										  
										  </if>
											</div>
                                </div>
								<br/>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-primary" type="submit" >保存</button>
                                    </div>
                                </div>
								<input type="hidden" name="apkurl" id="apkurl" value="{$apkurl}" />
                            </form>
                        </div>
                    </div>
                </div>

<script src="/Content/FileUpload/js/vendor/jquery.ui.widget.js"></script>
  <script src="/Content/FileUpload/js/jquery.iframe-transport.js"></script>
  <script src="/Content/FileUpload/js/jquery.fileupload.js"></script>
    <script src="/Content/layer/layer.js"></script>
	<script src="https://cdn.socket.io/socket.io-1.2.1.js"></script>
  <script>
 $(function () {
 initsocket();
                'use strict';
                var url = "/upload.php";
                $('#fileupload').fileupload({
                    autoUpload: true,//是否自动上传
                    url: url,
                    dataType: 'json',
                    done: function (e, data) {
                       
                        console.log(data.result);
                        if (data.result.error == 1) {
                            swal("上传出错了!", data.result.message, "success");
                        } else {
                            var pic = data.result.pic;
                            $("#showpic").html("<a target='_blank' href='/"+pic+"'>文件</a>");
                            $("#apkurl").val(pic);
							layer.msg("上传成功");


                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $('#progress .progress-bar').css(
                            'width',
                            progress + '%'
                        );
                    }
                }).prop('disabled', !$.support.fileInput)
                    .parent().addClass($.support.fileInput ? undefined : 'disabled');
					
		$(".push").click(function(){
			var json = {};
			json.type="update";
			json.content= "";
			json.zuid= 0;
			json.tvid= 0;
			var str= JSON.stringify(json);
			console.log(str);
			socket.emit('broadcast',str);
			swal("success!", "推送成功", "success");
		});
 
       

	});
function initsocket(){
	socket=io.connect('{$socket}');//与服务器进行连接		
}
</script>